# _*_ coding:utf-8 _*_
f1=open("Walden.txt",encoding="utf-8")
unm1=f1.read()
f1.close()
import re
unm2=unm1.lower()#大写变小写
unm2=re.sub('[;,.?;:"\'!-1234567890$+|/]',' ',unm2)#删除文章中的符号
unm2=unm2.replace("\ufeff","")
unm3=unm2.split()#变成单独的字符串
#载入模块统计单词出现的次数频率
from collections import Counter
rosult=Counter(unm3)
unm4=rosult.most_common()#单词出现频率次数统计
#变成字典
print("统计并输出为：")
unm5={}
for i in unm4:
    unm5[i[0]]=i[1]
print(unm5)

